]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
notificationDaemon: use different reason when replacing notification
authorCosimo Cecchi <cosimo@endlessm.com>
Thu, 11 Oct 2018 01:26:31 +0000 (18:26 -0700)
committerFlorian Müllner <florian.muellner@gmail.com>
Sat, 10 Nov 2018 10:56:49 +0000 (10:56 +0000)
Differently from the fd.o notifications, Gtk notifications do not
have a mechanism to update themselves. Instead, when a new
notification is received for an ID already known to the notification
daemon, the old notification is dismissed and a replaced with a new
one.

Currently though, there is no way to distinguish a notification that
was dismissed because of an user interaction, or because it was
replaced. That is an useful piece of information, so add a new value
to the NotificationDestroyedReason enum to account for it.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/258

js/ui/messageTray.js
js/ui/notificationDaemon.js

index 84681569ee7cf660182bba31990cf1b8c5c260a0..f8e2f0b9f907c6f18bf565b4f19b479d2243d424 100644 (file)
@@ -50,12 +50,15 @@ var State = {
 // These reasons are useful when we destroy the notifications received through
 // the notification daemon. We use EXPIRED for notifications that we dismiss
 // and the user did not interact with, DISMISSED for all other notifications
-// that were destroyed as a result of a user action, and SOURCE_CLOSED for the
-// notifications that were requested to be destroyed by the associated source.
+// that were destroyed as a result of a user action, SOURCE_CLOSED for the
+// notifications that were requested to be destroyed by the associated source,
+// and REPLACED for notifications that were destroyed as a consequence of a
+// newer version having replaced them.
 var NotificationDestroyedReason = {
     EXPIRED: 1,
     DISMISSED: 2,
-    SOURCE_CLOSED: 3
+    SOURCE_CLOSED: 3,
+    REPLACED: 4
 };
 
 // Message tray has its custom Urgency enumeration. LOW, NORMAL and CRITICAL
index 4d2be44edc40b22933c3e4805c973f0114729b32..609e562538e74f2d05a555c82a7cdd597a6d83a9 100644 (file)
@@ -690,7 +690,7 @@ var GtkNotificationDaemonAppSource = new Lang.Class({
         this._notificationPending = true;
 
         if (this._notifications[notificationId])
-            this._notifications[notificationId].destroy();
+            this._notifications[notificationId].destroy(MessageTray.NotificationDestroyedReason.REPLACED);
 
         let notification = this._createNotification(notificationParams);
         notification.connect('destroy', () => {